/*
 *  levelUpGame - RemoteIO.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef REMOTE_IO_H
#define REMOTE_IO_H

#include <vector>
#include "ofEvents.h"
#include "ofxDirList.h"
#include "ofxFileTransferServer.h"
//#include "ofxTCPServer.h"
#include "Settings.h"

using std::string;

class EventArgsPhotoboothFile : public ofEventArgs {
public:
	string filePath;
};

class RemoteIO {
public:
	typedef std::vector<string> vec_string;
	
	static const int DEFAULT_FILE_XFER_PORT;
	static const int DIR_SCAN_INTERVAL;
	
	EventArgsPhotoboothFile argsPhotoboothFile;
	ofEvent<EventArgsPhotoboothFile> onNewPhotoboothFile;
	
	
	RemoteIO();
	
	void setup( bool reportExistingFiles_ = false );
	void update();
	
private:
	static const float REPORT_DELAY;
	
	struct FileDelayInfo {
		FileDelayInfo( float ttr_, const string& p_ )
		: timeToReport( ttr_ ), filePath( p_ )
		{}
		
		float timeToReport;
		string filePath;
	};
	
	typedef std::vector<FileDelayInfo> vec_FileDelayInfo;
	
	
	const Settings& s;
	const string* photoboothPath;
	bool reportExistingFiles;
	
	vec_string knownPhotoboothFiles;
	vec_FileDelayInfo reportDelayFiles;
	
	ofxDirList dirLister;
	int nextDirScan;
	
	boost::shared_ptr<ofxFileTransferServer> fileXferServer;
//	ofxTCPServer tcpServer;
	
	vec_string* getNewPhotoboothFiles();
	void handleReportDelayFiles();
};

#endif /* ! REMOTE_IO_H */
